﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CCPnuts.ISkyDiskFileSystem.Interfaces;
using HgCo.WindowsLive.SkyDrive;
using CCPnuts.ISkyDiskFileSystem;
using System.Threading;

namespace SkyDiskFileSystem
{
    internal class SkyDisk : SkyElementContainer, I_SkyDisk
    {
        internal SkyDisk(SkyDriveWebClient client) : base(PackedInfos.SkyDisk, client, null, null) { }

        protected override WebFolderItemInfo[] GetItems()
        {
            return Client.ListRootWebFolderItems();
        }
    }

    internal class SSkyDisk : S_SkyDisk
    {
        #region S_SkyDisk Members

        public I_SkyDisk Login(string username, string password)
        {
            SkyDriveWebClient wc = new SkyDriveWebClient();
            wc.LogOn(username, password);
            var sd = new SkyDisk(wc);
            AutoUpdater.TaskList.Add(sd);
            lock (AutoUpdater.TaskList)
            {
                Monitor.Pulse(AutoUpdater.TaskList);
            }
            return sd;
        }

        #endregion
    }
}
